<%--
  Created by IntelliJ IDEA.
  User: landeqing
  Date: 2018/1/29
  Time: 22:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="/jquery/jquery-3.2.1.min.js"></script>
<html>
<head>
    <title>订单管理列表</title>
    <script type="text/javascript">

        function orderList(status) {
            var uid='${sessionScope.user.id}';
            window.location.href="/order/orderList?payStatus="+status+"&uid="+uid;
            if(status==null||status==""){
                window.location.href="/order/orderList?&uid="+uid;
            }
        }
        function updateStatus(orderId) {
            alert("确定取消订单吗？")
            var uid='${sessionScope.user.id}';
            window.location.href="/order/updateStatus?orderId="+orderId+"&uid="+uid;
        }
    </script>
    <title>订单表管理列表</title>
</head>
<body>
<div style="background-color: #dbdbdb">
    <table>
        <tr>
            <td><input type="button" value="全部订单" name="" onclick="orderList()"></td>&nbsp;&nbsp;&nbsp;
            <td><input type="button" value="待支付" name="" onclick="orderList(2)"></td>&nbsp;&nbsp;&nbsp;
            <td><input type="button" value="待发货" name="" onclick="orderList(1)"></td>
        </tr>
    </table>
</div>
<div style="background-color:powderblue;">
    <table border="1">
        <tr>
            <td>下单时间</td>
            <td>订单编号</td>
            <td>订单金额</td>
            <td>订单状态</td>
            <td>用户ID</td>
            <td>操作</td>
        </tr>
        <br><br>
        <c:forEach items="${orderList}" var="obj">
            <tr>
                <td>${obj.create_time}</td>
                <td class="orderId">${obj.order_id}</td>
                <td>${obj.total_price}</td>

                <td id="status_${obj.order_id}">
                    <c:choose>
                    <c:when test="${obj.pay_status==1}">待发货</c:when>
                    <c:when test="${obj.pay_status==2}">待支付</c:when>
                    <c:when test="${obj.pay_status==4}">订单已取消</c:when>
                    <c:when test="${obj.pay_status==5}">订单已过期</c:when>
                        <c:otherwise></c:otherwise>
                    </c:choose>
                </td>
                <td>${obj.uid}</td>
                <td><input type="button" value="取消订单" onclick="updateStatus(${obj.order_id})"></td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
